<div class="nav">
    <a href="{:U('index')}">管理员组列表</a>
    <a class="sel" href="{:U('add')}">添加管理员组</a>
</div>
<div class="add">
    <form method="post" action="" >
        <table class="table_add">
            <tr>
                <td width="100px">组名称</td>
                <td><input class="input1" type="text" name="group_name" id="group_name" value="" style="width:140px" /> </td>
            </tr>
            <tr>
                <td width="100px">顺序编号</td>
                <td><input class="input1" type="text" name="order_id" id="order_id" value="1000" style="width:60px" /> <label class="msg">*</label></td>
            </tr>
            <tr>
                <td width="100px">是否启用</td>
                <td><select name="is_enable" id="is_enable" class="sel1">
                        <option value="1">启用</option>
                        <option value="0">不启用</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>设置权限</td>
                <td><div class="purview_all"><label><input type="checkbox" name="purview_all" id="purview_all" value="1" /> 全选</label></div>
                    <foreach name="purview" item="item">
                        <dl class="dl_purview">
                            <dt><label><input type="checkbox" name="purview[]"  class="purview" value="{$item.purview_id}" /> {$item.purview_name}</label></dt>
                            <foreach name="item.sub" item="item_sub">
                            <dd><label><input type="checkbox" name="purview[]" class="purview_{$item.purview_id}" value="{$item_sub.purview_id}" /> {$item_sub.purview_name}</label></dd>
                            </foreach>
                        </dl>
                        <div class="c"></div>
                    </foreach>
                    <br />
                </td>
            </tr>
            <tr>
                <td></td>
                <td><input type="submit" class="btn1" value="提 交" /> &nbsp; <input class="btn4" type="reset" value="重 置" /> &nbsp; <input class="btn3"  type="button" onclick="window.history.back()" value="返 回" /></td>
            </tr>
        </table>
    </form>
</div>
<script type="text/javascript">
    $("#purview_all").click(function(){
	
       if($(this).is(':checked')) {
			
            $(".dl_purview").find('input[type="checkbox"]').prop("checked", true);
			
         } else {
            $(".dl_purview").find('input[type="checkbox"]').prop("checked", false);
         }
    })
    $(".purview").click(function(){
         var id = $(this).val();
         if($(this).is(':checked')) {
            $(".purview_"+id).prop("checked", true);
		  
         } else {
            $(".purview_"+id).prop("checked", false);
         }
    })
    function auto_check() {
        $(".dl_purview").each(function(){
            var aval = $(this).find("dd input:checked").val();
            if(aval == "" || typeof(aval) == "undefined") {
               $(this).find("dt input").removeAttr("checked");
            } else {
               $(this).find("dt input").attr("checked","checked");
            }
        });
    }
    $(".dl_purview dd input").click(function(){ auto_check();});
</script>